"use client"
import "./globals.css";
import {AntdRegistry} from "@ant-design/nextjs-registry";
import BasicLayout from "@/layouts/BasicLayout";
import React, {useCallback, useEffect} from "react";
import {Provider} from "react-redux";
import store from "@/stores";
import {getLoginUserUsingGet} from "@/api/userController";
import AccessLayout from "@/access/AccessLayout";

const InitLayout:React.FC<Readonly<{
    children: React.ReactNode;
}>> = ({children}) => {

    // 初始化全局用户状态
    const doInitLoginUser = useCallback(async () => {
        const res =  getLoginUserUsingGet();
        if (res.data === 0){
            // 更新全局用户状态

        }else {

        }
    }, [])
    useEffect(() => {
        doInitLoginUser()
    }, [])
    return children;
}



export default function RootLayout({
  children,
}: Readonly<{
  children: React.ReactNode;
}>) {

  return (
    <html lang="zh">
      <body>
      <AntdRegistry>
          <Provider store={store}>
              <BasicLayout>
                  <AccessLayout>
                      {children}
                  </AccessLayout>
              </BasicLayout>
          </Provider>
      </AntdRegistry>
      </body>
    </html>
  );
}
